new Vue({
	el: '#main',
	data: {
		phoneNo:"",
		city:"",
		country:"",
		address:"",
		name:"",
		companyName:"",
		imageFile:[],
		files:[]
	},
	methods: {
		plusReady: function() {
		},
		choiceImgFunc:function(item,index){
			var context = this;
//			this.activeIndex = index;
			var btnArray = [{
				title: "拍照"
			}, {
				title: "从相册选择"
			}];
			plus.nativeUI.actionSheet({
				title: "选择照片",
				cancel: "取消",
				buttons: btnArray
			}, function(e) {
				var index = e.index;
				switch(index) {
					case 0:
						break;
					case 1: //拍照，返回一个相对路径
						var cmr = plus.camera.getCamera();
						cmr.captureImage(function(p) {
							//把相对路径转为绝对路径，
							plus.io.resolveLocalFileSystemURL(p, function(entry) {
								entry.toLocalURL();
								item.src = entry.toLocalURL();
								context.files.push(entry.toLocalURL())
							}, function(e) {

							});

						}, function(e) {

						});
						break;
					case 2: //相册
						plus.gallery.pick(function(path) {
							plus.io.resolveLocalFileSystemURL(path, function(entry) {
								entry.toLocalURL();
								item.src = entry.toLocalURL();
								context.files.push(entry.toLocalURL())
							}, function(e) {

							});
						}, function(err) {

						}, { filter: "image" });
						break;
				}
			});

		},
		submit: function() {
//			if(!this.country){
//				mui.toast("请选择国家");
//				return
//			};
//			if(!this.city){
//				mui.toast("请选择城市");
//				return
//			};
//			if(!this.companyName){
//				mui.toast("请输入公司名称");
//				return
//			};
//			if(!this.name){
//				mui.toast("请输入代表姓名");
//				return
//			};
//			if(!this.phoneNo){
//				mui.toast("请输入联系方式");
//				return
//			};
//			if(this.files.length==0){
//				mui.toast("请上传报名材料");
//				return
//			};
			var jsonData = {
				orgName:this.companyName,
				country:this.country,
				city:this.city,
				orgAttr:this.address,
				file:this.files
			}
			ajAjax("app/sys/addUserOrg.do", jsonData, function(data) {
			}, function(err) {

			});
		},

	},
	mounted: function() {
		if(window.plus) {
			this.plusReady();
		} else {
			document.addEventListener("plusready", this.plusReady, false);
		}
	}
});